//
//  ProvinceModel.swift
//  Swift-Example
//
//  Created by apang on 2018/8/8.
//  Copyright © 2018 apang.men All rights reserved.
//

import Foundation
import RxCocoa
import RxSwift
import RxDataSources

public struct CityModel: Codable {
    public var diji: String
    public var quHuaDaiMa: String
    public var quhao: String
    public var shengji: String = ""
    public var xianji: String = ""
    public var children: [String]
}

public struct ProvinceModel: Codable{
    public var shengji: String
    public var quHuaDaiMa: String
    public var children: [Item]
    public var select: Bool? = false
}

extension ProvinceModel: SectionModelType {
    
    public typealias Item = CityModel
    
    public var items: [Item] {
        return children
    }
    
    public var isSelect: Bool {
        if (select == nil) {
            return false
        }
        return select!
    }
    
    public var header: String {
        return shengji
    }
    
    public init(original: ProvinceModel, items: [CityModel]) {
        self.shengji = original.shengji
        self.quHuaDaiMa = original.quHuaDaiMa
        self.select = original.select
        self.children = items
    }
}
